<template>
  <div id="address">
    <div class="address-top">
      <h3>发货地址</h3>
      <el-button type="primary" @click="dialogFormVisible = true">新增</el-button>
      <el-button type="primary">刷新</el-button>
    </div>
    <div class="address-content">
      <el-table height="500px" :data="addresss" border style="width: 100%;font-size: 13px;margin-left: 20px;">
        <el-table-column type="selection" width="55">
        </el-table-column>
        <el-table-column prop="contact" label="联系人" width="200">
        </el-table-column>
        <el-table-column prop="mobile" label="联系电话" width="200">
        </el-table-column>
        <el-table-column prop="province" label="省" width="150">
        </el-table-column>
        <el-table-column prop="city" label="市" width="120">
        </el-table-column>
        <el-table-column prop="county" label="区" width="120">
        </el-table-column>
        <el-table-column prop="postCode" label="邮政编码" width="120">
        </el-table-column>
        <el-table-column prop="addressDetail" label="详细地址" width="120">
        </el-table-column>
        <el-table-column prop="isDefault" label="默认地址" width="150">
        </el-table-column>
        <el-table-column prop="status" label="是否启用" width="120">
          <template slot-scope="scope">
            <el-switch v-model="scope.row.status" active-color="#66b1ff" inactive-color="#c1c1c1" active-value="1"
              inactive-value="0">
            </el-switch>
          </template>
        </el-table-column>
        <el-table-column label="操作" width="100">
          <template slot-scope="scope">
            <el-button @click="handleClick(scope.row)" type="text" size="small">查看</el-button>
            <el-button type="text" size="small">编辑</el-button>
          </template>
        </el-table-column>
      </el-table>
    </div>
    <el-pagination style="position: relative;left: 700px;bottom: 30px;" @size-change="handleSizeChange"
      @current-change="handleCurrentChange" :current-page="currentPage4" :page-sizes="[100, 200, 300, 400]"
      :page-size="100" layout="total, sizes, prev, pager, next, jumper" :total="400">
    </el-pagination>
    <el-dialog width="700px" top="20px" title="新增账户" :visible.sync="dialogFormVisible">
      <AddAddress />
      <div slot="footer" class="dialog-footer">
        <el-button @click="dialogFormVisible = false">取 消</el-button>
        <el-button type="primary" @click="dialogFormVisible = false">确 定</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import AddAddress from './AddAddress.vue';

export default {
  name: 'Address',
  components: {
    AddAddress
  },
  data() {
    return {
      dialogFormVisible: false,
      //分页参数
      currentPage1: 5,
      currentPage2: 5,
      currentPage3: 5,
      currentPage4: 4,
      addresss: [
        {
          contact: 'test1',
          mobile: 'test1',
          province: '1',
          city: '湖南',
          county: '岳阳',
          postCode: '岳阳楼区',
          addressDetail: '1',
          isDefault: '0',
          status: '1'
        },
        {
          contact: 'test1',
          mobile: 'test1',
          province: '1',
          city: '湖南',
          county: '岳阳',
          postCode: '岳阳楼区',
          addressDetail: '1',
          isDefault: '0',
          status: '1'
        }, {
          contact: 'test1',
          mobile: 'test1',
          province: '1',
          city: '湖南',
          county: '岳阳',
          postCode: '岳阳楼区',
          addressDetail: '1',
          isDefault: '0',
          status: '1'
        },
      ]
    }

  },
  methods: {
    handleSizeChange(val) {
      console.log(`每页 ${val} 条`);
    },
    handleCurrentChange(val) {
      console.log(`当前页: ${val}`);
    }
  }
}
</script>

<style scoped>
#address {
  width: 100%;
  height: 100%;
}

.address-top {
  width: calc(100% -20px);
  height: 60px;
  /* background-color: pink; */
  line-height: 60px;
  padding-left: 20px;
  font-size: 13px;
}

.address-top h3 {
  display: inline-block;
  margin-right: 1000px;
}

.address-content {
  width: 100%;
  height: calc(100% - 60px);
  /* background-color: skyblue; */
}

.el-input,
.el-button {
  font-size: 13px;
}
</style>